﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cesave.Domain.PermisosModule.Contracts.Concesiones;
using Cesave.Infrastructure.CrossCutting.IoC;
using Cesave.Infrastructure.CrossCutting.Logging;
using Cesave.DistributedServices.Core.ErrorHandlers;
using System.ServiceModel;

namespace Cesave.DistributedServices.PermisosModule
{
    public partial class PermisosModuleService
    {
    public void AddConcesion(Domain.PermisosModule.Entities.Concesion concesion)
        {
            try
            {
                IConcesionService concesionservice = IoCFactory.Resolve<IConcesionService>();
                concesionservice.AddConcesion(concesion);
            }
            catch (Exception ex)
            {
                ITraceManager tracemanager = IoCFactory.Resolve<ITraceManager>();
                tracemanager.TraceError(ex.Message);
                ServiceError details = ServiceError.Factory(ex.Message);
                throw new FaultException<ServiceError>(details);
            }
        }

        public void ChangeConcesion(Domain.PermisosModule.Entities.Concesion concesion)
        {
            try
            {
                IConcesionService concesionservice = IoCFactory.Resolve<IConcesionService>();
                concesionservice.ChangeConcesion(concesion);
            }
            catch (Exception ex)
            {
                ITraceManager tracemanager = IoCFactory.Resolve<ITraceManager>();
                tracemanager.TraceError(ex.Message);
                ServiceError details = ServiceError.Factory(ex.Message);
                throw new FaultException<ServiceError>(details);
            }
        }

        public Domain.PermisosModule.Entities.Concesion FindConcesionByGuidSpecification(Guid concesionGuid)
        {
            try
            {
                IConcesionService concesionservice = IoCFactory.Resolve<IConcesionService>();
                return concesionservice.FindConcesionByGuid(concesionGuid);
            }
            catch (Exception ex)
            {
                ITraceManager tracemanager = IoCFactory.Resolve<ITraceManager>();
                tracemanager.TraceError(ex.Message);
                ServiceError details = ServiceError.Factory(ex.Message);
                throw new FaultException<ServiceError>(details);
            }
        }
    }
}
